home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / egs-tools / egs_dev-disk / egsincludes / egsgadbox.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-06  |  15.1 KB  |  407 lines

  1. #ifndef EGS_EGSGADBOX_H
  2. #define EGS_EGSGADBOX_H
  3.  
  4. /***************************************************************************\
  5. *
  6. *  $
  7. *  $ FILE     : egsgadbox.h
  8. *  $ VERSION  : 1
  9. *  $ REVISION : 7
  10. *  $ DATE     : 08-Dec-93 12:45
  11. *  $
  12. *  $ Author   : mvk
  13. *  $
  14. *
  15. ****************************************************************************
  16. *                                                                          *
  17. * (c) Copyright 1990/94 VIONA Development                                  *
  18. *     All Rights Reserved                                                  *
  19. *                                                                          *
  20. \***************************************************************************/
  21.  
  22. #ifndef         EXEC_TYPES_H
  23. #include        <exec/types.h>
  24. #endif
  25. #ifndef         EGS_EGSGFX_H
  26. #include        <egs/egsgfx.h>
  27. #endif
  28. #ifndef         EGS_EGSINTUI_H
  29. #include        <egs/egsintui.h>
  30. #endif
  31. #ifndef         EGS_EGSINTUIGFX_H
  32. #include        <egs/egsintuigfx.h>
  33. #endif
  34.  
  35. /*
  36.  * The EGSgadbox.library is the basic library for font sensitive and resizeable
  37.  * gadgets/requesters. The programmer defines the shape of a requester by
  38.  * a recursive structure of boxes, a gadget box tree. The elements of this tree
  39.  * can be gadgets, rendering routines or ordering boxes, that contain several
  40.  * other boxes and order them in a given way. From this tree a list of gadgets
  41.  * and a rendering programm for additional graphics is calculated.
  42.  *
  43.  * The elements of this tree are generated using the function of this library,
  44.  * and linked together by two functions. Lower elements in the tree serve as
  45.  * additional graphics or gadgets for higher elements or gadgets. By the usage
  46.  * of fillboxes and borderboxes, the elements can be grouped and separated.
  47.  *
  48.  * Example for a color modification gadget, using three scrollers with arrows
  49.  *
  50.  * Treestructure:
  51.  *
  52.  * unknown, gadget : Master gadget for the requester
  53.  * | horizontal, draw : Rectangle surrounding
  54.  * | | unknown, - : horizontal fill box
  55.  * | | vertical, - : grouping for the first prop gadget
  56.  * | | | unknwon, gadget : upper arrow gadget, first scroller
  57.  * | | | | horizontal, draw : Rectangle surrounding the arrow
  58.  * | | | | | unknown, - : horizontal fill box
  59.  * | | | | | vertical, - :
  60.  * | | | | | | unknown, - : vertical fill box
  61.  * | | | | | | unknown, draw : dynamic rendering of an arrow
  62.  * | | | | | | unknown, - : vertical fill box
  63.  * | | | | | unknown, - : horizontal fill box
  64.  * | | | unknwon, gadget : scroller gadget, including its rendering
  65.  * | | | unknwon, gadget : lower arrow gadget, first scroller
  66.  * | | | | horizontal, draw : Rectangle surrounding the arrow
  67.  * | | | | | unknown, - : horizontal fill box
  68.  * | | | | | vertical, - :
  69.  * | | | | | | unknown, - : vertical fill box
  70.  * | | | | | | unknown, draw : dynamic rendering of an arrow
  71.  * | | | | | | unknown, - : vertical fill box
  72.  * | | | | | unknown, - : horizontal fill box
  73.  * | | unknown, - : horizontal fill box
  74.  * | | vertical, - : grouping for the second prop gadget
  75.  * | | | unknwon, gadget : upper arrow gadget, secode scroller
  76.  * | | | | horizontal, draw : Rectangle surrounding the arrow
  77.  * | | | | | unknown, - : horizontal fill box
  78.  * | | | | | vertical, - :
  79.  * | | | | | | unknown, - : vertical fill box
  80.  * | | | | | | unknown, draw : dynamic rendering of an arrow
  81.  * | | | | | | unknown, - : vertical fill box
  82.  * | | | | | unknown, - : horizontal fill box
  83.  * | | | unknwon, gadget : scroller gadget, including its rendering
  84.  * | | | unknwon, gadget : lower arrow gadget, first scroller
  85.  * | | | | horizontal, draw : Rectangle surrounding the arrow
  86.  * | | | | | unknown, - : horizontal fill box
  87.  * | | | | | vertical, - :
  88.  * | | | | | | unknown, - : vertical fill box
  89.  * | | | | | | unknown, draw : dynamic rendering of an arrow
  90.  * | | | | | | unknown, - : vertical fill box
  91.  * | | | | | unknown, - : horizontal fill box
  92.  *
  93.  *   ...
  94.  *
  95.  *
  96.  * Assuming con contains a valid EB_GadContext, and b1 and b2 are EB_GadBoxPtr,
  97.  * this structure can be created by:
  98.  *
  99.  
  100.  b1 = EB_CreateHorizBox(con);
  101.  EB_AddLastSon(b1,EB_CreateHorizFill(con,0,0));
  102.  EB_AddLastSon(b1,EB_CreateSuperVertiProp(con,255,16,0,0x1000,
  103.                                           EB_DEC_UP_LEFT|EB_INC_BOTTOM_RIGHT));
  104.  EB_AddLastSon(b1,EB_CreateHorizFill(con,0,0));
  105.  EB_AddLastSon(b1,EB_CreateSuperVertiProp(con,255,16,0,0x1001,
  106.                                           EB_DEC_UP_LEFT|EB_INC_BOTTOM_RIGHT));
  107.  EB_AddLastSon(b1,EB_CreateHorizFill(con,0,0));
  108.  EB_AddLastSon(b1,EB_CreateSuperVertiProp(con,255,16,0,0x1002,
  109.                                           EB_DEC_UP_LEFT|EB_INC_BOTTOM_RIGHT));
  110.  EB_AddLastSon(b1,EB_CreateHorizFill(con,0,0));
  111.  root = EB_CreateMaster(con,0x4711,0x1010);
  112.  EB_AddLastSon(root, EB_CreateFrontBorder(con, b1, EB_FILL_ALL));
  113.  
  114.  *
  115.  * From this gadget tree a list of gadgets and a rendering programm can be
  116.  * calculated using EB_ProcessGadBoxes.
  117.  *
  118.  */
  119.  
  120. /*
  121.  * EB_ContextPtr
  122.  *
  123.  * Pointer to a structure that keeps track of allocated memory. This is used
  124.  * to allocate the memory for the temporary tree, and permanent gadgets.
  125.  */
  126.  
  127. typedef APTR EB_ContextPtr;
  128.  
  129. typedef struct EB_GadBox *EB_GadBoxPtr;
  130.  
  131. /*
  132.  * EB_ResBox
  133.  *
  134.  * The library uses this structure to return locations and sizes of custom
  135.  * boxes in the created requester/window. A pointer to this structure is
  136.  * passed to EB_CreateResponseBox.
  137.  *
  138.  */
  139.  
  140. typedef struct EB_ResBox *EB_ResBoxPtr;
  141.  
  142. struct EB_ResBox { WORD X, Y, W, H; };
  143.  
  144. /*
  145.  * EB_InfoBox
  146.  *
  147.  * Extension to the EB_ResBox structure, for changing textuell information
  148.  *
  149.  */
  150.  
  151. typedef struct EB_InfoBox *EB_InfoBoxPtr;
  152.  
  153. struct EB_InfoBox {
  154.          EG_EFontPtr       Font;
  155.          UBYTE             Justify;
  156.          UBYTE             Pad0;
  157.          UWORD             Pad1;
  158.          struct EB_ResBox  Box;
  159. };
  160.  
  161. /*
  162.  * Fill flags, needed at several locations, to determine on which sides
  163.  * further filling is recommended or posible.
  164.  *
  165.  */
  166.  
  167. #define EB_FILL_LEFT   1
  168. #define EB_FILL_RIGHT  2
  169. #define EB_FILL_TOP    4
  170. #define EB_FILL_BOTTOM 8
  171. #define EB_FILL_ALL    (EB_FILL_LEFT|EB_FILL_RIGHT|EB_FILL_TOP|EB_FILL_BOTTOM)
  172.  
  173. /*
  174.  * Types/orientation of gadboxes:
  175.  *
  176.  *  EB_HORIZONTAL  : the box may have several sons, which are
  177.  *                   ordered horizontal
  178.  *  EB_VERTICAL    : the box may have several sons, which are
  179.  *                   ordered vertical
  180.  *  EB_UNKNOWN     : the box may have only one son
  181.  *  EB_HORIZTABLE  : the box may have several sons, which may
  182.  *                   either be unknown, or vertical. All vertical
  183.  *                   sons must have the same number of sons,
  184.  *                   because the grandsons are ordered in a table.
  185.  *  EB_VERTITABLE  : the box may have several sons, which may
  186.  *                   either be unknown, or horizontal. All
  187.  *                   horizontal sons must have the same number of
  188.  *                   sons, because the grandsons are ordered in a
  189.  *                   table.
  190.  *  EB_SELECT      : the box may have several sons, which all lay
  191.  *                   at the same location.
  192.  */
  193.  
  194. #define EB_HORIZONTAL 0
  195. #define EB_VERTICAL   1
  196. #define EB_UNKNOWN    2
  197. #define EB_HORIZTABLE 3
  198. #define EB_VERTITABLE 4
  199. #define EB_SELECT     5
  200.  
  201. /*
  202.  * The aim of a gadgbox is given in the type field, possible values are:
  203.  *
  204.  *  EB_GADGET    : The box is to create a gadget. A pointer to the gadget
  205.  *                 has to be put into the "gad" field.
  206.  *  EB_DRAW      : The box contains a draing routine, which is specified by
  207.  *                 the "draw" field.
  208.  *  EB_WINDOW    : The box has a pointer to a new window structure in its
  209.  *                 "new" field.
  210.  *  EB_LATE      : The meaning of the box is not yet clear. Through rendering
  211.  *                 the "call" procedure is called with a pointer to the
  212.  *                 gadget in A0.
  213.  *  EB_RESPONSE  : The box returns its size and location back to the user,
  214.  *                 using a supplied EB_ResBox structure.
  215.  */
  216. #define EB_GADGET     0
  217. #define EB_DRAW       1
  218. #define EB_WINDOW     2
  219. #define EB_LATE       3
  220. #define EB_RESPONSE   4
  221.  
  222. typedef APTR EB_GBCreate;
  223.  
  224. /*
  225.  * EB_GadBox
  226.  *
  227.  * The primary element of a gadbox tree. This boxes may not be created by
  228.  * the programm, only by using functions from this or other EGB libraries.
  229.  * All boxes are discarded, after the calculation of the real gadgets.
  230.  *
  231.  *   .Prev,
  232.  *   .Next      : chaining of elements in the same level
  233.  *   .Father    : pointer to the upper element
  234.  *   .First,
  235.  *   .Last      : pointers to the first and last elements of the leafs of this
  236.  *                node
  237.  *   .Orient    : orientation
  238.  *   .MinWidth,
  239.  *   .MinHeight : minimal size of the box
  240.  *   .MaxWidth,
  241.  *   .MaxHeight : maximal size of the box
  242.  *   .X, .Y     : location, only valid after calculation
  243.  *   .Pri       : priority of the box
  244.  *                If there is more room in a row/collumn, than needed by the
  245.  *                elements, the additional space is spread over all elements
  246.  *                of the highest priority until their maximum is reached. Then
  247.  *                the elements with the next priority are stretched. This is
  248.  *                continued, until there is no more space, or all elements
  249.  *                are stretched to their maximum. In this case the additional
  250.  *                space is used to center the elements in the surrounding box.
  251.  *   .Con       : pointer to associated gadget context
  252.  *   .Type      : type of gadbox
  253.  *    .Gad      : pointer to a gadget, that is resized and rendered by
  254.  *                this box
  255.  *    .Draw     : drawing routine that is resized and located by this box
  256.  *    .New      : pointer to new window structure that is filled using the
  257.  *                informations of this box
  258.  *    .Call     : Routine that is called during calculation, when all the boxes
  259.  *                have their location and size. This routine may modify the
  260.  *                box itself, as all calculation is performed on its son, after
  261.  *                the call. This box type can be used to gain a list of gadgets,
  262.  *                whichs number depends on the size of the surrounding box.
  263.  *    .Res      : pointer to EB_ResInfo structure, to be filled with information
  264.  *                after calculation is done
  265.  *    .Selector : Routine that is called after calculation for an EB_select box
  266.  *                that carries a gadget. The routine is called once for each
  267.  *                son element with parameters, the parent box in A0, the number
  268.  *                of the sons in D0 and the render routine of the son in A1.
  269.  *    .UserData : free for user data, very handy for late or select boxes
  270.  *
  271.  */
  272. typedef struct EB_GadContextNode *EB_GadContext;
  273.  
  274. struct EB_GadBox{
  275.          EB_GadBoxPtr  Prev, Next, Father, First, Last;
  276.          UBYTE         Orient;
  277.          UBYTE         Pad1;
  278.          WORD          MinWidth, MaxWidth, MinHeight, MaxHeight;
  279.          WORD          X, Y;
  280.          BYTE          Pri;
  281.          UBYTE         Pad2;
  282.          EB_GadContext Con;
  283.          UBYTE         Type;
  284.          UBYTE          Pad3;
  285.          UWORD          Pad4;
  286.  
  287.          union {
  288.                  EI_GadgetPtr          Gad;
  289.                  IG_IntuiGfxPtr        Draw;
  290.                  struct EI_NewWindow  *New;
  291.                  EB_GBCreate           Call;
  292.                  EB_ResBoxPtr          Res;
  293.                } Render;
  294.  
  295.          APTR         Selector;
  296.          APTR         UserData;
  297. };
  298. /*
  299.  * Errormessages, supported by the .error field in the gadget context:
  300.  *
  301.  *  EB_OK                        : no error
  302.  *  EB_NOT_ENOUGH_MEMORY         : not enough memory for operation available
  303.  *  EB_UNKNOWN_WITH_MULTIPLE_SONS: a gadget with unknown location but several
  304.  *                                 sons was discoverd during calculation.
  305.  *  EB_STRING_GAD_NOT_FOUND      : A call to EB_LinkStringGadgets was done,
  306.  *                                 but the referenced gadgets could not be
  307.  *                                 found.
  308.  *  EB_ILLEGAL_SELECT            : A select box was discovered, which was no
  309.  *                                 gadget, or had no select call supported.
  310.  *  EB_UNKNOWN_FONT, EB_BAD_FONTS: The EB_CreateGadContext routine was called
  311.  *                                 with illegal fonts.
  312.  *  EB_NO_GAD_SOLUTION           : The library could not find a possible
  313.  *                                 solution for the given gadget box tree.
  314.  *  EB_UNMATCHING_TABLES         : A gadget table was discovered during
  315.  *                                 calculation, whichs sons had different
  316.  *                                 numbers of elements.
  317.  */
  318.  
  319. #define EB_OK                        0;
  320. #define EB_NOT_ENOUGH_MEMORY         0x4000;
  321. #define EB_UNKNOWN_WITH_MULTIPLESONS 0x4001;
  322. #define EB_STRINGGAD_NOT_FOUND       0x4002;
  323. #define EB_ILLEGAL_SELECT            0x4003;
  324. #define EB_UNKNOWN_FONT              0x4004;
  325. #define EB_NO_WINDOW                 0x4005;
  326. #define EB_NO_GAD_SOLUTION           0x4006;
  327. #define EB_BAD_FONTS                 0x4007;
  328. #define EB_UNMATCHING_TABLES         0x4008;
  329.  
  330. #define EB_OWN_FONT  1
  331. #define EB_OWN_TFONT 2
  332.  
  333. /*
  334.  * EB_GadContext
  335.  *
  336.  * Structure that keeps track and information for a gadget box tree and the
  337.  * resulting list of gadgets and renderings. All box creating routines need
  338.  * this context as parameter. This structure is created and initialized using
  339.  * EB_CreateGadContext. When it is deleted using EB_DeleteGadContext, all
  340.  * asociated boxes, gadgets and rendering informations are also discarded,
  341.  * so make sure, not to delete the context, before you closed the window.
  342.  *
  343.  *  .Gadres      : permanent context, that keeps existing after the gadgets
  344.  *                 have been calculated.
  345.  *  .Helres      : temporary context, that is deleted, after the gadgets have
  346.  *                 been calculated.
  347.  *  .FHeight,
  348.  *  .FWidth      : the size of the capital "M" in the desired font.
  349.  *  .Font        : font for gadget elements, and additional rendering
  350.  *  .TFont       : font for textgadgets and information fields
  351.  *  .NewWin      : pointer to EI_NewWindow structure, which is valid after
  352.  *                 calculation.
  353.  *  .First       : pointer to first gadget in the created list
  354.  *  .Num         : number of gadgets in this list
  355.  *  .Color, Back : colors for 24 bit gadgets
  356.  *  .Error       : errorconditions that occur during operation
  357.  */
  358.  
  359. struct EB_GadContextNode {
  360.          EB_ContextPtr        Gadres, Helpres;
  361.          WORD                 FHeight, FWidth;
  362.          EG_EFontPtr          Font, TFont;
  363.          struct EI_NewWindow  *NewWin;
  364.          EI_GadgetPtr         First;
  365.          WORD                 Num;
  366.          UWORD                Pad1;
  367.          ULONG                Color, Back;
  368.          UBYTE                Flags;
  369.          UBYTE                Pad;
  370.          UWORD                Error;
  371. };
  372.  
  373. typedef char           *EB_StrArray[];
  374. typedef EB_StrArray    *EB_StrArrayPtr;
  375. typedef EB_StrArrayPtr  EB_StrArray2[];
  376. typedef EB_StrArray2   *EB_StrArray2Ptr;
  377.  
  378. typedef struct EB_SPropGadget *EB_SPropGadPtr;
  379.  
  380. struct EB_SPropGadget {
  381.          struct EI_MasterGadget Master;
  382.          EI_PropGadPtr          RealProp;
  383. };
  384.  
  385. /*
  386. *  EB_Max, EB_Min : extrem sizes for gadget boxes, serve as don't care
  387. */
  388.  
  389.  
  390.  
  391. #define EB_GAD_MAX   32767
  392. #define EB_GAD_MIN   0
  393.  
  394. /*
  395.  * Arrow locations in SuperPropGadgets
  396.  */
  397.  
  398. #define EB_DEC_UP_LEFT      1
  399. #define EB_DEC_BOTTOM_RIGHT 2
  400. #define EB_INC_UP_LEFT      4
  401. #define EB_INC_BOTTOM_RIGHT 8
  402.  
  403. #endif  /* EGS_EGSGADBOX_H */
  404.  
  405.  
  406.  
  407.